package com.wenli.lt.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wenli.lt.entity.Information;
import com.wenli.lt.mapper.InformationMapper;
import com.wenli.lt.service.IInformationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lt
 * @since 2021-03-24
 */
@Service
public class InformationServiceImpl extends ServiceImpl<InformationMapper, Information> implements IInformationService {

    @Autowired
    InformationMapper informationMapper;
    @Override
    public List<Information> getInformationsList(String studentNumber) {
        QueryWrapper<Information> queryWrapper = new QueryWrapper();
        queryWrapper.eq("beSendStudentNumber",studentNumber);
        return informationMapper.selectList(queryWrapper);
    }

    @Override
    public Boolean setRead(List<String> informationIds) {
        informationMapper.setRead(informationIds);
        return true;
    }

    @Override
    public Boolean AddInformation(Information information) {
        information.setInformationId(UUID.randomUUID().toString().replace("-",""));
        return 1 == informationMapper.insert(information);
    }
}
